package lamma.lab2.job;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * @author maxcellent
 *
 */
@Target({ElementType.FIELD})
@Retention(RUNTIME)
public @interface ProvidedBy {
	
	/**
	 * @author maxcellent
	 *
	 */
	// TODO : move to ReflectionHelper
	public static class Resolver {
		
		/**
		 * TODO : expression language to be supported
		 * 
		 * @param param
		 * @return
		 */
		public static String [] resolveFullPath(String param) {
			if (param == null || param.isEmpty()) {
				return new String[0];
			} else {
				return param.split("\\.");
			}
		}
		
		public static String resolveRoot(String param) {
			String [] fullPath = resolveFullPath(param);
			return fullPath == null ? null : fullPath[0];
		}
	}
	
	/**
	 * the job / context that feeds the value
	 * 
	 * @return
	 */
	Class<?> job();
	
	String [] params() default {};
	
	/**
	 * some additional steps may be required to perform some validation
	 * 
	 * @return
	 */
	//TODO
	String afterStep() default "";
	
	String result();
}
